﻿using K8.EF;
using KingerRobot.PCRMES.Dao;
using System.Linq.Expressions;

namespace KingerRobot.PCRMES.SpiService;

/// <summary>
/// ME入库订单
/// </summary>
public  interface IWmsOrderRepositories
{
    #region 同步查询
    /// <summary>
    /// 根据Id查询实体
    /// </summary>
    /// <param name="objId"></param>
    /// <returns></returns>
    i_wms_order QueryById(string objId);
    /// <summary>
    /// 根据id数组查询实体list
    /// </summary>
    /// <param name="lstIds"></param>
    /// <returns></returns>
    List<i_wms_order> QueryByIDs(object[] lstIds);

    /// <summary>
    /// 写入实体数据
    /// </summary>
    /// <param name="entity">博文实体类</param>
    /// <returns>插入个数 插入成功为1</returns>
    public int Add(i_wms_order entity)
    {
        var _db = Db.Default;
        return _db.WmsOrders.Insert(entity);
    }

    /// <summary>
    /// 批量插入实体
    /// </summary>
    /// <param name="listEntity">实体集合</param>
    /// <returns>影响行数</returns>
    public int Add(IEnumerable<i_wms_order> listEntity)
    {
        var _db = Db.Default;
        _db.WmsOrders.AddRange(listEntity);
        int insertedCount = _db.SaveChanges();
        return insertedCount;
    }
    /// <summary>
    /// 更新model
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    int Update(i_wms_order model);

    /// <summary>
    /// 根据model，更新，带where条件
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="strWhere"></param>
    /// <returns></returns>
    int Update(Expression<Func<i_wms_order, bool>> whereExpression, i_wms_order entity);

    /// <summary>
    /// 正序查询第一条数据
    /// </summary>
    /// <returns></returns>
    i_wms_order First();
    /// <summary>
    /// 根据条件查询查询第一条数据
    /// </summary>
    /// <param name="whereExpression"></param>
    /// <returns></returns>
    i_wms_order First(Expression<Func<i_wms_order, bool>> whereExpression);

    /// <summary>
    /// 查询
    /// </summary>
    /// <returns></returns>
    List<i_wms_order> Query();


    /// <summary>
    /// 根据表达式查询
    /// </summary>
    /// <param name="whereExpression"></param>
    /// <returns></returns>
    List<i_wms_order> Query(Expression<Func<i_wms_order, bool>> whereExpression);

    #endregion
}
